{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e861787f",
   "metadata": {},
   "source": [
    "## 本周知识点\n",
    "\n",
    "### 1. 字典的初始 （{key:value}）\n",
    "\n",
    "> 1. [字典的文档](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) \n",
    "> 2. 字典的重要属性：\n",
    ">> 1. 结构：key:value（键值对）\n",
    ">> 2. 字典是无序的，我们通过键(key)去查找值(value)，就好像list用索引(index)查找值(value)一样，只不过字典的“索引”被定义了名字\n",
    ">> 3. 字典对key的定义有一定的要求：key是由\"不可变\"的数据结构才可以定义，list是不能作为key来定义的。\n",
    ">> 4. 字典的key是唯一的，字典的值value也可以不唯一。（list的值是唯一的么？）\n",
    "> 3. 字典的创建\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a9a7121b",
   "metadata": {},
   "outputs": [],
   "source": [
    "users = [\n",
    "    [\"zhichao\",23,\"IT\",20000],\n",
    "    [\"xiaoming\",26,\"IT\",30000]\n",
    "    \n",
    "]\n",
    "# 试对比：\n",
    "users_dict = {\n",
    "    \"zhichao\":[23,\"IT\",20000],\n",
    "    \"xiaoming\":[26,\"IT\",30000]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "513fda71",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['xiaoming', 26, 'IT', 30000]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查询xiaoming的信息：\n",
    "users[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "71c51218",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[26, 'IT', 30000]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users_dict[\"xiaoming\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c67def3",
   "metadata": {},
   "source": [
    "* 试问：如果users的数据很大，我想查其中的一个信息，但无法知道其索引值\n",
    "* list就变得很无力，\n",
    "* 而dict只需要知道数据的关键信息即可"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36b690dc",
   "metadata": {},
   "source": [
    "### 2. 字典的创建(常见的三种创建方式)\n",
    "> 1. info = {key1:value1 , key2:value2 , ...}直接按照字典格式创建\n",
    "> 2. info_02 = dict(key1=value1 , key2=value2 , ... ) 使用dict()进行字典创建\n",
    "> 3. 运用字典增加的方式新建字典:\n",
    "``` \n",
    "info_03 = {} info_03[key1] = value1 ,info_03[key2] = value2 ... \n",
    "``` \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "04c2e950",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua', 'stu10003': 'xiaohong'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "info = {\n",
    "    \"stu10001\":\"xiaoming\",\n",
    "    \"stu10002\":\"lihua\",\n",
    "    \"stu10003\":\"xiaohong\",\n",
    "#     \"stu10004\":\"xiaohong\",\n",
    "}\n",
    "print(info)\n",
    "print(type(info))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "39d3eddb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua', 'stu10003': 'xiaohong'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "info_02 = dict(\n",
    "    stu10001=\"xiaoming\",\n",
    "    stu10002=\"lihua\",\n",
    "    stu10003=\"xiaohong\",\n",
    ")\n",
    "print(info_02)\n",
    "print(type(info_02))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "eed4d39f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua', 'stu10003': 'xiaohong'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "info_03 = {} # 新建空字典\n",
    "info_03[\"stu10001\"] = \"xiaoming\"\n",
    "info_03[\"stu10002\"] = \"lihua\"\n",
    "info_03[\"stu10003\"] = \"xiaohong\"\n",
    "print(info_03)\n",
    "print(type(info_03))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d641e69",
   "metadata": {},
   "source": [
    "### 字典的增、删、改、查\n",
    "\n",
    "> 1. 字典的增加(和字典的第三种创建方式一致)：\n",
    ">> * info_03[\"stu10004\"] = \"zhichao\"\n",
    "> 2. 字典的查询\n",
    ">> * info_03[key_name]\n",
    ">> * 注意： 正确的查询方式，应该先查询key是否存在字典当中，如下：\n",
    ">>> 1. key_name in info_03  ## 查看是否存在,如果存在，返回结果为 True ，不存在为 False\n",
    ">>> 2. info_03[key_name]\n",
    "> 3. 字典的修改\n",
    ">> 1. 查询key是否存在 \n",
    ">> 2. 修改key的值\n",
    ">>> * 例如： 修改info_03中stu10003的值为Alex, if \"stu10003\" in info_03 : info_03 [\"stu10003\"] = \"Alex\"\n",
    "> 4. 字典的删除\n",
    ">> 1.pop(key)\n",
    ">> 2.popitem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "b199d081",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua', 'stu10003': 'xiaohong', 'stu10004': 'zhichao'}\n"
     ]
    }
   ],
   "source": [
    "info_03 [\"stu10004\"] = \"zhichao\"\n",
    "print(info_03)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "3f1b18bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'xiaohong'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 用key查到value的数据\n",
    "info_03[\"stu10003\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "f03706fd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "查询的key不存在\n"
     ]
    }
   ],
   "source": [
    "# 正确的查询字典方式\n",
    "print(\"stu10003\" in info_03)\n",
    "if \"stu10006\" in info_03:\n",
    "    print(info_03[\"stu10006\"])\n",
    "else:\n",
    "    print(\"查询的key不存在\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "24893a15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua', 'stu10003': 'Alex', 'stu10004': 'zhichao'}\n"
     ]
    }
   ],
   "source": [
    "# 修改: 也要先查询key\n",
    "if \"stu10003\" in info_03:\n",
    "    info_03 [\"stu10003\"] = \"Alex\"\n",
    "print(info_03)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "39933ef5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua', 'stu10004': 'zhichao'}\n"
     ]
    }
   ],
   "source": [
    "# 字典的删除\n",
    "info_03.pop(\"stu10003\")\n",
    "print(info_03)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "795afd55",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'stu10001': 'xiaoming', 'stu10002': 'lihua'}\n"
     ]
    }
   ],
   "source": [
    "# 字典的删除 popitem()\n",
    "info_03.popitem()\n",
    "print(info_03)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "bb1935ed",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on dict object:\n",
      "\n",
      "class dict(object)\n",
      " |  dict() -> new empty dictionary\n",
      " |  dict(mapping) -> new dictionary initialized from a mapping object's\n",
      " |      (key, value) pairs\n",
      " |  dict(iterable) -> new dictionary initialized as if via:\n",
      " |      d = {}\n",
      " |      for k, v in iterable:\n",
      " |          d[k] = v\n",
      " |  dict(**kwargs) -> new dictionary initialized with the name=value pairs\n",
      " |      in the keyword argument list.  For example:  dict(one=1, two=2)\n",
      " |  \n",
      " |  Built-in subclasses:\n",
      " |      StgDict\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __contains__(self, key, /)\n",
      " |      True if the dictionary has the specified key, else False.\n",
      " |  \n",
      " |  __delitem__(self, key, /)\n",
      " |      Delete self[key].\n",
      " |  \n",
      " |  __eq__(self, value, /)\n",
      " |      Return self==value.\n",
      " |  \n",
      " |  __ge__(self, value, /)\n",
      " |      Return self>=value.\n",
      " |  \n",
      " |  __getattribute__(self, name, /)\n",
      " |      Return getattr(self, name).\n",
      " |  \n",
      " |  __getitem__(...)\n",
      " |      x.__getitem__(y) <==> x[y]\n",
      " |  \n",
      " |  __gt__(self, value, /)\n",
      " |      Return self>value.\n",
      " |  \n",
      " |  __init__(self, /, *args, **kwargs)\n",
      " |      Initialize self.  See help(type(self)) for accurate signature.\n",
      " |  \n",
      " |  __iter__(self, /)\n",
      " |      Implement iter(self).\n",
      " |  \n",
      " |  __le__(self, value, /)\n",
      " |      Return self<=value.\n",
      " |  \n",
      " |  __len__(self, /)\n",
      " |      Return len(self).\n",
      " |  \n",
      " |  __lt__(self, value, /)\n",
      " |      Return self<value.\n",
      " |  \n",
      " |  __ne__(self, value, /)\n",
      " |      Return self!=value.\n",
      " |  \n",
      " |  __repr__(self, /)\n",
      " |      Return repr(self).\n",
      " |  \n",
      " |  __reversed__(self, /)\n",
      " |      Return a reverse iterator over the dict keys.\n",
      " |  \n",
      " |  __setitem__(self, key, value, /)\n",
      " |      Set self[key] to value.\n",
      " |  \n",
      " |  __sizeof__(...)\n",
      " |      D.__sizeof__() -> size of D in memory, in bytes\n",
      " |  \n",
      " |  clear(...)\n",
      " |      D.clear() -> None.  Remove all items from D.\n",
      " |  \n",
      " |  copy(...)\n",
      " |      D.copy() -> a shallow copy of D\n",
      " |  \n",
      " |  get(self, key, default=None, /)\n",
      " |      Return the value for key if key is in the dictionary, else default.\n",
      " |  \n",
      " |  items(...)\n",
      " |      D.items() -> a set-like object providing a view on D's items\n",
      " |  \n",
      " |  keys(...)\n",
      " |      D.keys() -> a set-like object providing a view on D's keys\n",
      " |  \n",
      " |  pop(...)\n",
      " |      D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n",
      " |      If key is not found, d is returned if given, otherwise KeyError is raised\n",
      " |  \n",
      " |  popitem(self, /)\n",
      " |      Remove and return a (key, value) pair as a 2-tuple.\n",
      " |      \n",
      " |      Pairs are returned in LIFO (last-in, first-out) order.\n",
      " |      Raises KeyError if the dict is empty.\n",
      " |  \n",
      " |  setdefault(self, key, default=None, /)\n",
      " |      Insert key with a value of default if key is not in the dictionary.\n",
      " |      \n",
      " |      Return the value for key if key is in the dictionary, else default.\n",
      " |  \n",
      " |  update(...)\n",
      " |      D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.\n",
      " |      If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]\n",
      " |      If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v\n",
      " |      In either case, this is followed by: for k in F:  D[k] = F[k]\n",
      " |  \n",
      " |  values(...)\n",
      " |      D.values() -> an object providing a view on D's values\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  fromkeys(iterable, value=None, /) from builtins.type\n",
      " |      Create a new dictionary with keys from iterable and values set to value.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(*args, **kwargs) from builtins.type\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  __hash__ = None\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(info_03)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b18ebf2f",
   "metadata": {},
   "source": [
    "### 字典的练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "59171c61",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院 = {'status': '1',\n",
    " 'regeocode': {'roads': [{'id': '020F49F0050461206',\n",
    "    'location': '113.678,23.6284',\n",
    "    'direction': '北',\n",
    "    'name': '博学路',\n",
    "    'distance': '7.63232'},\n",
    "   {'id': '020F49F0050462229',\n",
    "    'location': '113.679,23.6245',\n",
    "    'direction': '北',\n",
    "    'name': '老虎形街',\n",
    "    'distance': '445.159'},\n",
    "   {'id': '020F49F0050462451',\n",
    "    'location': '113.677,23.6347',\n",
    "    'direction': '南',\n",
    "    'name': '中山路',\n",
    "    'distance': '708.299'}],\n",
    "  'roadinters': [{'second_name': '中山路',\n",
    "    'first_id': '020F49F0050461206',\n",
    "    'second_id': '020F49F0050462451',\n",
    "    'location': '113.676794,23.634661',\n",
    "    'distance': '708.299',\n",
    "    'first_name': '博学路',\n",
    "    'direction': '南'}],\n",
    "  'formatted_address': '广东省广州市从化区温泉镇博学路',\n",
    "  'addressComponent': {'city': '广州市',\n",
    "   'province': '广东省',\n",
    "   'adcode': '440117',\n",
    "   'district': '从化区',\n",
    "   'towncode': '440117100000',\n",
    "   'streetNumber': {'number': '24号',\n",
    "    'location': '113.677267,23.629149',\n",
    "    'direction': '西北',\n",
    "    'distance': '129.943',\n",
    "    'street': '博学路'},\n",
    "   'country': '中国',\n",
    "   'township': '温泉镇',\n",
    "   'businessAreas': [[]],\n",
    "   'building': {'name': [], 'type': []},\n",
    "   'neighborhood': {'name': [], 'type': []},\n",
    "   'citycode': '020'},\n",
    "  'aois': [],\n",
    "  'pois': [{'id': 'B0FFG4TAF2',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
    "    'poiweight': '0.237309',\n",
    "    'name': '广州南方公寓',\n",
    "    'location': '113.678983,23.627778',\n",
    "    'distance': '102.617',\n",
    "    'tel': '13622768437',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0H6FA18J5',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院南侧)',\n",
    "    'poiweight': '0.223065',\n",
    "    'name': '保利半山花园',\n",
    "    'location': '113.679358,23.627672',\n",
    "    'distance': '139.054',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅区'},\n",
    "   {'id': 'B00140TWHT',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '笃行路2',\n",
    "    'poiweight': '0.157653',\n",
    "    'name': '教工住宅1号',\n",
    "    'location': '113.678490,23.630432',\n",
    "    'distance': '222.658',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0FFHRJDM9',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '中大南方学院南门1号',\n",
    "    'poiweight': '0.256152',\n",
    "    'name': '中南公寓',\n",
    "    'location': '113.680349,23.627573',\n",
    "    'distance': '231.723',\n",
    "    'tel': '13711245345',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0HGD588HJ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼4号',\n",
    "    'location': '113.677460,23.630490',\n",
    "    'distance': '242.901',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFHZH0IK',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路广州南方学院综合楼内',\n",
    "    'poiweight': '0.17934',\n",
    "    'name': '地下铁',\n",
    "    'location': '113.677941,23.629029',\n",
    "    'distance': '74.1376',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
    "   {'id': 'B0HGDU76L2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院2号实验楼',\n",
    "    'location': '113.678211,23.630956',\n",
    "    'distance': '280.003',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP838K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路25',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼3号(外国语学院)',\n",
    "    'location': '113.677247,23.630947',\n",
    "    'distance': '298.093',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU8NLD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院1号实验楼',\n",
    "    'location': '113.678215,23.631370',\n",
    "    'distance': '326.007',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD58UTU',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院2号教学楼',\n",
    "    'location': '113.677060,23.631346',\n",
    "    'distance': '346.352',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B00140MR9A',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号',\n",
    "    'poiweight': '0.450402',\n",
    "    'name': '广州南方学院',\n",
    "    'location': '113.679262,23.632583',\n",
    "    'distance': '471.564',\n",
    "    'tel': '020-87828988;020-61787331',\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU92JD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': [],\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼1号',\n",
    "    'location': '113.677077,23.631783',\n",
    "    'distance': '391.548',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD592BJ',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道886号广州南方学院内',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院综合楼',\n",
    "    'location': '113.680117,23.631544',\n",
    "    'distance': '392.731',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP81F0',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路19号附近',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼1号(文学与传媒学院)',\n",
    "    'location': '113.676866,23.631736',\n",
    "    'distance': '393.93',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFLBEOND',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.190963',\n",
    "    'name': '聚贤楼10号',\n",
    "    'location': '113.681253,23.631036',\n",
    "    'distance': '418.51',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0FFH6K3U9',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
    "    'poiweight': '0.254885',\n",
    "    'name': '广州中大南方招待所',\n",
    "    'location': '113.676330,23.631332',\n",
    "    'distance': '378.102',\n",
    "    'tel': '020-61787222',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGD58NF8',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院达人书院',\n",
    "    'location': '113.679041,23.632392',\n",
    "    'distance': '446.366',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFKUVYWV',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '保利桃花源',\n",
    "    'poiweight': '0.273168',\n",
    "    'name': '广州和风庭阿七度假别墅',\n",
    "    'location': '113.681736,23.630569',\n",
    "    'distance': '424.35',\n",
    "    'tel': '18681565305',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGDU99RM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内',\n",
    "    'poiweight': '0.257947',\n",
    "    'name': '广州南方学院图书馆',\n",
    "    'location': '113.679177,23.632762',\n",
    "    'distance': '489.331',\n",
    "    'tel': '020-61787368;020-61787371',\n",
    "    'type': '科教文化服务;图书馆;图书馆'},\n",
    "   {'id': 'B0HGDU92JC',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院4号实验楼',\n",
    "    'location': '113.679963,23.632652',\n",
    "    'distance': '498.883',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFL7C054',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
    "    'poiweight': '0.317505',\n",
    "    'name': '广州U优森特酒店',\n",
    "    'location': '113.679226,23.632528',\n",
    "    'distance': '464.819',\n",
    "    'tel': '15813395296',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0FFG8CSEK',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.185371',\n",
    "    'name': 'L5员工宿舍',\n",
    "    'location': '113.682583,23.631487',\n",
    "    'distance': '554.129',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0HGD58FR2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼9号',\n",
    "    'location': '113.679747,23.633032',\n",
    "    'distance': '532.163',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HG5Z9JNK',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221553',\n",
    "    'name': '广州南方学院教学楼7号',\n",
    "    'location': '113.678600,23.633330',\n",
    "    'distance': '544.868',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD599JM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院第11教学楼',\n",
    "    'location': '113.680037,23.633173',\n",
    "    'distance': '556.036',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0GUJYPEG2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
    "    'poiweight': '0.216026',\n",
    "    'name': '怒烤烤串(从化店)',\n",
    "    'location': '113.677160,23.632910',\n",
    "    'distance': '510.112',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅'},\n",
    "   {'id': 'B0HGDU6Z41',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼6号',\n",
    "    'location': '113.678424,23.633710',\n",
    "    'distance': '586.331',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD580NZ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路7号附近',\n",
    "    'poiweight': '0.285712',\n",
    "    'name': '广州南方学院惟贤门',\n",
    "    'location': '113.678437,23.633721',\n",
    "    'distance': '587.601',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU7T1K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院教学楼10号',\n",
    "    'location': '113.680125,23.633492',\n",
    "    'distance': '592.504',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0HGDU76L1',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '中山路与博学路交叉口东南150米',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼5号',\n",
    "    'location': '113.678046,23.633982',\n",
    "    'distance': '616.848',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'}]},\n",
    " 'info': 'OK',\n",
    " 'infocode': '10000'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "bd804308",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'regeocode': {'roads': [{'id': '020F49F0050461206',\n",
       "    'location': '113.678,23.6284',\n",
       "    'direction': '北',\n",
       "    'name': '博学路',\n",
       "    'distance': '7.63232'},\n",
       "   {'id': '020F49F0050462229',\n",
       "    'location': '113.679,23.6245',\n",
       "    'direction': '北',\n",
       "    'name': '老虎形街',\n",
       "    'distance': '445.159'},\n",
       "   {'id': '020F49F0050462451',\n",
       "    'location': '113.677,23.6347',\n",
       "    'direction': '南',\n",
       "    'name': '中山路',\n",
       "    'distance': '708.299'}],\n",
       "  'roadinters': [{'second_name': '中山路',\n",
       "    'first_id': '020F49F0050461206',\n",
       "    'second_id': '020F49F0050462451',\n",
       "    'location': '113.676794,23.634661',\n",
       "    'distance': '708.299',\n",
       "    'first_name': '博学路',\n",
       "    'direction': '南'}],\n",
       "  'formatted_address': '广东省广州市从化区温泉镇博学路',\n",
       "  'addressComponent': {'city': '广州市',\n",
       "   'province': '广东省',\n",
       "   'adcode': '440117',\n",
       "   'district': '从化区',\n",
       "   'towncode': '440117100000',\n",
       "   'streetNumber': {'number': '24号',\n",
       "    'location': '113.677267,23.629149',\n",
       "    'direction': '西北',\n",
       "    'distance': '129.943',\n",
       "    'street': '博学路'},\n",
       "   'country': '中国',\n",
       "   'township': '温泉镇',\n",
       "   'businessAreas': [[]],\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'citycode': '020'},\n",
       "  'aois': [],\n",
       "  'pois': [{'id': 'B0FFG4TAF2',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       "    'poiweight': '0.237309',\n",
       "    'name': '广州南方公寓',\n",
       "    'location': '113.678983,23.627778',\n",
       "    'distance': '102.617',\n",
       "    'tel': '13622768437',\n",
       "    'type': '商务住宅;住宅区;住宅小区'},\n",
       "   {'id': 'B0H6FA18J5',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': '从莞深高速(广州南方学院南侧)',\n",
       "    'poiweight': '0.223065',\n",
       "    'name': '保利半山花园',\n",
       "    'location': '113.679358,23.627672',\n",
       "    'distance': '139.054',\n",
       "    'tel': [],\n",
       "    'type': '商务住宅;住宅区;住宅区'},\n",
       "   {'id': 'B00140TWHT',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '笃行路2',\n",
       "    'poiweight': '0.157653',\n",
       "    'name': '教工住宅1号',\n",
       "    'location': '113.678490,23.630432',\n",
       "    'distance': '222.658',\n",
       "    'tel': [],\n",
       "    'type': '商务住宅;住宅区;住宅小区'},\n",
       "   {'id': 'B0FFHRJDM9',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': '中大南方学院南门1号',\n",
       "    'poiweight': '0.256152',\n",
       "    'name': '中南公寓',\n",
       "    'location': '113.680349,23.627573',\n",
       "    'distance': '231.723',\n",
       "    'tel': '13711245345',\n",
       "    'type': '商务住宅;住宅区;住宅小区'},\n",
       "   {'id': 'B0HGD588HJ',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院教学楼4号',\n",
       "    'location': '113.677460,23.630490',\n",
       "    'distance': '242.901',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0FFHZH0IK',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路广州南方学院综合楼内',\n",
       "    'poiweight': '0.17934',\n",
       "    'name': '地下铁',\n",
       "    'location': '113.677941,23.629029',\n",
       "    'distance': '74.1376',\n",
       "    'tel': [],\n",
       "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
       "   {'id': 'B0HGDU76L2',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院2号实验楼',\n",
       "    'location': '113.678211,23.630956',\n",
       "    'distance': '280.003',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0FFKP838K',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路25',\n",
       "    'poiweight': '0.191742',\n",
       "    'name': '教学楼3号(外国语学院)',\n",
       "    'location': '113.677247,23.630947',\n",
       "    'distance': '298.093',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;高等院校'},\n",
       "   {'id': 'B0HGDU8NLD',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院1号实验楼',\n",
       "    'location': '113.678215,23.631370',\n",
       "    'distance': '326.007',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0HGD58UTU',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.191229',\n",
       "    'name': '广州南方学院2号教学楼',\n",
       "    'location': '113.677060,23.631346',\n",
       "    'distance': '346.352',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B00140MR9A',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.450402',\n",
       "    'name': '广州南方学院',\n",
       "    'location': '113.679262,23.632583',\n",
       "    'distance': '471.564',\n",
       "    'tel': '020-87828988;020-61787331',\n",
       "    'type': '科教文化服务;学校;高等院校'},\n",
       "   {'id': 'B0HGDU92JD',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': [],\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院教学楼1号',\n",
       "    'location': '113.677077,23.631783',\n",
       "    'distance': '391.548',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0HGD592BJ',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道886号广州南方学院内',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院综合楼',\n",
       "    'location': '113.680117,23.631544',\n",
       "    'distance': '392.731',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0FFKP81F0',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路19号附近',\n",
       "    'poiweight': '0.191742',\n",
       "    'name': '教学楼1号(文学与传媒学院)',\n",
       "    'location': '113.676866,23.631736',\n",
       "    'distance': '393.93',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "   {'id': 'B0FFLBEOND',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.190963',\n",
       "    'name': '聚贤楼10号',\n",
       "    'location': '113.681253,23.631036',\n",
       "    'distance': '418.51',\n",
       "    'tel': [],\n",
       "    'type': '商务住宅;住宅区;宿舍'},\n",
       "   {'id': 'B0FFH6K3U9',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
       "    'poiweight': '0.254885',\n",
       "    'name': '广州中大南方招待所',\n",
       "    'location': '113.676330,23.631332',\n",
       "    'distance': '378.102',\n",
       "    'tel': '020-61787222',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       "   {'id': 'B0HGD58NF8',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "    'poiweight': '0.191229',\n",
       "    'name': '广州南方学院达人书院',\n",
       "    'location': '113.679041,23.632392',\n",
       "    'distance': '446.366',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "   {'id': 'B0FFKUVYWV',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '保利桃花源',\n",
       "    'poiweight': '0.273168',\n",
       "    'name': '广州和风庭阿七度假别墅',\n",
       "    'location': '113.681736,23.630569',\n",
       "    'distance': '424.35',\n",
       "    'tel': '18681565305',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       "   {'id': 'B0HGDU99RM',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.257947',\n",
       "    'name': '广州南方学院图书馆',\n",
       "    'location': '113.679177,23.632762',\n",
       "    'distance': '489.331',\n",
       "    'tel': '020-61787368;020-61787371',\n",
       "    'type': '科教文化服务;图书馆;图书馆'},\n",
       "   {'id': 'B0HGDU92JC',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院4号实验楼',\n",
       "    'location': '113.679963,23.632652',\n",
       "    'distance': '498.883',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0FFL7C054',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
       "    'poiweight': '0.317505',\n",
       "    'name': '广州U优森特酒店',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'distance': '464.819',\n",
       "    'tel': '15813395296',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       "   {'id': 'B0FFG8CSEK',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.185371',\n",
       "    'name': 'L5员工宿舍',\n",
       "    'location': '113.682583,23.631487',\n",
       "    'distance': '554.129',\n",
       "    'tel': [],\n",
       "    'type': '商务住宅;住宅区;宿舍'},\n",
       "   {'id': 'B0HGD58FR2',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院教学楼9号',\n",
       "    'location': '113.679747,23.633032',\n",
       "    'distance': '532.163',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0HG5Z9JNK',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221553',\n",
       "    'name': '广州南方学院教学楼7号',\n",
       "    'location': '113.678600,23.633330',\n",
       "    'distance': '544.868',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0HGD599JM',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院第11教学楼',\n",
       "    'location': '113.680037,23.633173',\n",
       "    'distance': '556.036',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0GUJYPEG2',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
       "    'poiweight': '0.216026',\n",
       "    'name': '怒烤烤串(从化店)',\n",
       "    'location': '113.677160,23.632910',\n",
       "    'distance': '510.112',\n",
       "    'tel': [],\n",
       "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅'},\n",
       "   {'id': 'B0HGDU6Z41',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院教学楼6号',\n",
       "    'location': '113.678424,23.633710',\n",
       "    'distance': '586.331',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'},\n",
       "   {'id': 'B0HGD580NZ',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路7号附近',\n",
       "    'poiweight': '0.285712',\n",
       "    'name': '广州南方学院惟贤门',\n",
       "    'location': '113.678437,23.633721',\n",
       "    'distance': '587.601',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;高等院校'},\n",
       "   {'id': 'B0HGDU7T1K',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.191229',\n",
       "    'name': '广州南方学院教学楼10号',\n",
       "    'location': '113.680125,23.633492',\n",
       "    'distance': '592.504',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "   {'id': 'B0HGDU76L1',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '中山路与博学路交叉口东南150米',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院教学楼5号',\n",
       "    'location': '113.678046,23.633982',\n",
       "    'distance': '616.848',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;学校'}]},\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000'}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "6d4c9140",
   "metadata": {},
   "outputs": [],
   "source": [
    "教工住宅1号_name = 广州南方学院['regeocode']['pois'][2]['name']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "6c1456f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'教工住宅1号'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "教工住宅1号_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "d48a6408",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 取出教工住宅1号的信息\n",
    "教工住宅1号_name = 广州南方学院['regeocode']['pois'][2]['name']\n",
    "教工住宅1号_address = 广州南方学院['regeocode']['pois'][2]['address']\n",
    "教工住宅1号_localtion = 广州南方学院['regeocode']['pois'][2]['location']\n",
    "教工住宅1号_type = 广州南方学院['regeocode']['pois'][2]['type']\n",
    "教工住宅1号_direction = 广州南方学院['regeocode']['pois'][2]['direction']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "9cb700f3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "教工住宅1号\n",
      "笃行路2\n",
      "113.678490,23.630432\n",
      "商务住宅;住宅区;住宅小区\n",
      "北\n"
     ]
    }
   ],
   "source": [
    "print(教工住宅1号_name)\n",
    "print(教工住宅1号_address)\n",
    "print(教工住宅1号_localtion)\n",
    "print(教工住宅1号_type)\n",
    "print(教工住宅1号_direction)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "7a912018",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "老虎形街\n",
      "020F49F0050462229\n",
      "113.679,23.6245\n",
      "445.159\n",
      "北\n"
     ]
    }
   ],
   "source": [
    "# 取出中山路的信息\n",
    "老虎形街_name = 广州南方学院[ 'regeocode']['roads'][1]['name']\n",
    "老虎形街_id = 广州南方学院[ 'regeocode']['roads'][1]['id']\n",
    "老虎形街_location = 广州南方学院[ 'regeocode']['roads'][1]['location']\n",
    "老虎形街_distance = 广州南方学院[ 'regeocode']['roads'][1]['distance']\n",
    "老虎形街_direction = 广州南方学院[ 'regeocode']['roads'][1]['direction']\n",
    "print(老虎形街_name)\n",
    "print(老虎形街_id)\n",
    "print(老虎形街_location)\n",
    "print(老虎形街_distance)\n",
    "print(老虎形街_direction)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "0834051d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': '020F49F0050462229', 'location': '113.679,23.6245', 'direction': '北', 'name': '老虎形街', 'distance': '445.159'}\n"
     ]
    }
   ],
   "source": [
    "# 另一种方法\n",
    "老虎形街 = 广州南方学院[ 'regeocode']['roads'][1]\n",
    "print(老虎形街)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "fd11a28d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 所有的_name = []?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a8f1cae",
   "metadata": {},
   "source": [
    "#### 请完成如下字典操作和列表操作的目标：\n",
    "* 1. 取出一个'roads'\n",
    "* 2. 取出一个'roads' 的 'name' 道路名字\n",
    "* 3. 取出一个'roads' 的 'direction' 路的朝向\n",
    "\n",
    "-----\n",
    "* 进阶：\n",
    "* 4. 取出对应的 pois name 所对应的 name 并存成一个list 如name_list = [...]\n",
    "* 5. 取出所有的 pois name 以及其对应的 信息 并分别存成对应的list 如name_location_list = [...]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72785bf9",
   "metadata": {},
   "source": [
    "###  初尝试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "91183c75",
   "metadata": {},
   "outputs": [],
   "source": [
    "all_pois = 广州南方学院['regeocode']['pois'][:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "19758138",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 'B0FFG4TAF2',\n",
       "  'direction': '东南',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       "  'poiweight': '0.237309',\n",
       "  'name': '广州南方公寓',\n",
       "  'location': '113.678983,23.627778',\n",
       "  'distance': '102.617',\n",
       "  'tel': '13622768437',\n",
       "  'type': '商务住宅;住宅区;住宅小区'},\n",
       " {'id': 'B0H6FA18J5',\n",
       "  'direction': '东南',\n",
       "  'businessarea': [],\n",
       "  'address': '从莞深高速(广州南方学院南侧)',\n",
       "  'poiweight': '0.223065',\n",
       "  'name': '保利半山花园',\n",
       "  'location': '113.679358,23.627672',\n",
       "  'distance': '139.054',\n",
       "  'tel': [],\n",
       "  'type': '商务住宅;住宅区;住宅区'},\n",
       " {'id': 'B00140TWHT',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '笃行路2',\n",
       "  'poiweight': '0.157653',\n",
       "  'name': '教工住宅1号',\n",
       "  'location': '113.678490,23.630432',\n",
       "  'distance': '222.658',\n",
       "  'tel': [],\n",
       "  'type': '商务住宅;住宅区;住宅小区'},\n",
       " {'id': 'B0FFHRJDM9',\n",
       "  'direction': '东南',\n",
       "  'businessarea': [],\n",
       "  'address': '中大南方学院南门1号',\n",
       "  'poiweight': '0.256152',\n",
       "  'name': '中南公寓',\n",
       "  'location': '113.680349,23.627573',\n",
       "  'distance': '231.723',\n",
       "  'tel': '13711245345',\n",
       "  'type': '商务住宅;住宅区;住宅小区'},\n",
       " {'id': 'B0HGD588HJ',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院教学楼4号',\n",
       "  'location': '113.677460,23.630490',\n",
       "  'distance': '242.901',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0FFHZH0IK',\n",
       "  'direction': '西北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路广州南方学院综合楼内',\n",
       "  'poiweight': '0.17934',\n",
       "  'name': '地下铁',\n",
       "  'location': '113.677941,23.629029',\n",
       "  'distance': '74.1376',\n",
       "  'tel': [],\n",
       "  'type': '餐饮服务;冷饮店;冷饮店'},\n",
       " {'id': 'B0HGDU76L2',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院2号实验楼',\n",
       "  'location': '113.678211,23.630956',\n",
       "  'distance': '280.003',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0FFKP838K',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路25',\n",
       "  'poiweight': '0.191742',\n",
       "  'name': '教学楼3号(外国语学院)',\n",
       "  'location': '113.677247,23.630947',\n",
       "  'distance': '298.093',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;高等院校'},\n",
       " {'id': 'B0HGDU8NLD',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路附近',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院1号实验楼',\n",
       "  'location': '113.678215,23.631370',\n",
       "  'distance': '326.007',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0HGD58UTU',\n",
       "  'direction': '西北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路',\n",
       "  'poiweight': '0.191229',\n",
       "  'name': '广州南方学院2号教学楼',\n",
       "  'location': '113.677060,23.631346',\n",
       "  'distance': '346.352',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B00140MR9A',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道882号',\n",
       "  'poiweight': '0.450402',\n",
       "  'name': '广州南方学院',\n",
       "  'location': '113.679262,23.632583',\n",
       "  'distance': '471.564',\n",
       "  'tel': '020-87828988;020-61787331',\n",
       "  'type': '科教文化服务;学校;高等院校'},\n",
       " {'id': 'B0HGDU92JD',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': [],\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院教学楼1号',\n",
       "  'location': '113.677077,23.631783',\n",
       "  'distance': '391.548',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0HGD592BJ',\n",
       "  'direction': '东北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道886号广州南方学院内',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院综合楼',\n",
       "  'location': '113.680117,23.631544',\n",
       "  'distance': '392.731',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0FFKP81F0',\n",
       "  'direction': '西北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路19号附近',\n",
       "  'poiweight': '0.191742',\n",
       "  'name': '教学楼1号(文学与传媒学院)',\n",
       "  'location': '113.676866,23.631736',\n",
       "  'distance': '393.93',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       " {'id': 'B0FFLBEOND',\n",
       "  'direction': '东北',\n",
       "  'businessarea': [],\n",
       "  'address': '从莞深高速(广州南方学院)',\n",
       "  'poiweight': '0.190963',\n",
       "  'name': '聚贤楼10号',\n",
       "  'location': '113.681253,23.631036',\n",
       "  'distance': '418.51',\n",
       "  'tel': [],\n",
       "  'type': '商务住宅;住宅区;宿舍'},\n",
       " {'id': 'B0FFH6K3U9',\n",
       "  'direction': '西北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
       "  'poiweight': '0.254885',\n",
       "  'name': '广州中大南方招待所',\n",
       "  'location': '113.676330,23.631332',\n",
       "  'distance': '378.102',\n",
       "  'tel': '020-61787222',\n",
       "  'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       " {'id': 'B0HGD58NF8',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "  'poiweight': '0.191229',\n",
       "  'name': '广州南方学院达人书院',\n",
       "  'location': '113.679041,23.632392',\n",
       "  'distance': '446.366',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       " {'id': 'B0FFKUVYWV',\n",
       "  'direction': '东北',\n",
       "  'businessarea': [],\n",
       "  'address': '保利桃花源',\n",
       "  'poiweight': '0.273168',\n",
       "  'name': '广州和风庭阿七度假别墅',\n",
       "  'location': '113.681736,23.630569',\n",
       "  'distance': '424.35',\n",
       "  'tel': '18681565305',\n",
       "  'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       " {'id': 'B0HGDU99RM',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道882号广州南方学院内',\n",
       "  'poiweight': '0.257947',\n",
       "  'name': '广州南方学院图书馆',\n",
       "  'location': '113.679177,23.632762',\n",
       "  'distance': '489.331',\n",
       "  'tel': '020-61787368;020-61787371',\n",
       "  'type': '科教文化服务;图书馆;图书馆'},\n",
       " {'id': 'B0HGDU92JC',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路附近',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院4号实验楼',\n",
       "  'location': '113.679963,23.632652',\n",
       "  'distance': '498.883',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0FFL7C054',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
       "  'poiweight': '0.317505',\n",
       "  'name': '广州U优森特酒店',\n",
       "  'location': '113.679226,23.632528',\n",
       "  'distance': '464.819',\n",
       "  'tel': '15813395296',\n",
       "  'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       " {'id': 'B0FFG8CSEK',\n",
       "  'direction': '东北',\n",
       "  'businessarea': [],\n",
       "  'address': '从莞深高速(广州南方学院)',\n",
       "  'poiweight': '0.185371',\n",
       "  'name': 'L5员工宿舍',\n",
       "  'location': '113.682583,23.631487',\n",
       "  'distance': '554.129',\n",
       "  'tel': [],\n",
       "  'type': '商务住宅;住宅区;宿舍'},\n",
       " {'id': 'B0HGD58FR2',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '广州南方学院',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院教学楼9号',\n",
       "  'location': '113.679747,23.633032',\n",
       "  'distance': '532.163',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0HG5Z9JNK',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路',\n",
       "  'poiweight': '0.221553',\n",
       "  'name': '广州南方学院教学楼7号',\n",
       "  'location': '113.678600,23.633330',\n",
       "  'distance': '544.868',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0HGD599JM',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道882号广州南方学院',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院第11教学楼',\n",
       "  'location': '113.680037,23.633173',\n",
       "  'distance': '556.036',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0GUJYPEG2',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
       "  'poiweight': '0.216026',\n",
       "  'name': '怒烤烤串(从化店)',\n",
       "  'location': '113.677160,23.632910',\n",
       "  'distance': '510.112',\n",
       "  'tel': [],\n",
       "  'type': '餐饮服务;中餐厅;特色/地方风味餐厅'},\n",
       " {'id': 'B0HGDU6Z41',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '温泉大道882',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院教学楼6号',\n",
       "  'location': '113.678424,23.633710',\n",
       "  'distance': '586.331',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'},\n",
       " {'id': 'B0HGD580NZ',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '博学路7号附近',\n",
       "  'poiweight': '0.285712',\n",
       "  'name': '广州南方学院惟贤门',\n",
       "  'location': '113.678437,23.633721',\n",
       "  'distance': '587.601',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;高等院校'},\n",
       " {'id': 'B0HGDU7T1K',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '从莞深高速(广州南方学院)',\n",
       "  'poiweight': '0.191229',\n",
       "  'name': '广州南方学院教学楼10号',\n",
       "  'location': '113.680125,23.633492',\n",
       "  'distance': '592.504',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       " {'id': 'B0HGDU76L1',\n",
       "  'direction': '北',\n",
       "  'businessarea': [],\n",
       "  'address': '中山路与博学路交叉口东南150米',\n",
       "  'poiweight': '0.221662',\n",
       "  'name': '广州南方学院教学楼5号',\n",
       "  'location': '113.678046,23.633982',\n",
       "  'distance': '616.848',\n",
       "  'tel': [],\n",
       "  'type': '科教文化服务;学校;学校'}]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_pois"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "03f12354",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(0, {'id': 'B0FFG4TAF2', 'direction': '东南', 'businessarea': [], 'address': '温泉镇乌土村松浪队5号(近博学路)', 'poiweight': '0.237309', 'name': '广州南方公寓', 'location': '113.678983,23.627778', 'distance': '102.617', 'tel': '13622768437', 'type': '商务住宅;住宅区;住宅小区'})\n",
      "(1, {'id': 'B0H6FA18J5', 'direction': '东南', 'businessarea': [], 'address': '从莞深高速(广州南方学院南侧)', 'poiweight': '0.223065', 'name': '保利半山花园', 'location': '113.679358,23.627672', 'distance': '139.054', 'tel': [], 'type': '商务住宅;住宅区;住宅区'})\n",
      "(2, {'id': 'B00140TWHT', 'direction': '北', 'businessarea': [], 'address': '笃行路2', 'poiweight': '0.157653', 'name': '教工住宅1号', 'location': '113.678490,23.630432', 'distance': '222.658', 'tel': [], 'type': '商务住宅;住宅区;住宅小区'})\n",
      "(3, {'id': 'B0FFHRJDM9', 'direction': '东南', 'businessarea': [], 'address': '中大南方学院南门1号', 'poiweight': '0.256152', 'name': '中南公寓', 'location': '113.680349,23.627573', 'distance': '231.723', 'tel': '13711245345', 'type': '商务住宅;住宅区;住宅小区'})\n",
      "(4, {'id': 'B0HGD588HJ', 'direction': '北', 'businessarea': [], 'address': '博学路', 'poiweight': '0.221662', 'name': '广州南方学院教学楼4号', 'location': '113.677460,23.630490', 'distance': '242.901', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(5, {'id': 'B0FFHZH0IK', 'direction': '西北', 'businessarea': [], 'address': '博学路广州南方学院综合楼内', 'poiweight': '0.17934', 'name': '地下铁', 'location': '113.677941,23.629029', 'distance': '74.1376', 'tel': [], 'type': '餐饮服务;冷饮店;冷饮店'})\n",
      "(6, {'id': 'B0HGDU76L2', 'direction': '北', 'businessarea': [], 'address': '博学路', 'poiweight': '0.221662', 'name': '广州南方学院2号实验楼', 'location': '113.678211,23.630956', 'distance': '280.003', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(7, {'id': 'B0FFKP838K', 'direction': '北', 'businessarea': [], 'address': '博学路25', 'poiweight': '0.191742', 'name': '教学楼3号(外国语学院)', 'location': '113.677247,23.630947', 'distance': '298.093', 'tel': [], 'type': '科教文化服务;学校;高等院校'})\n",
      "(8, {'id': 'B0HGDU8NLD', 'direction': '北', 'businessarea': [], 'address': '博学路附近', 'poiweight': '0.221662', 'name': '广州南方学院1号实验楼', 'location': '113.678215,23.631370', 'distance': '326.007', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(9, {'id': 'B0HGD58UTU', 'direction': '西北', 'businessarea': [], 'address': '博学路', 'poiweight': '0.191229', 'name': '广州南方学院2号教学楼', 'location': '113.677060,23.631346', 'distance': '346.352', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(10, {'id': 'B00140MR9A', 'direction': '北', 'businessarea': [], 'address': '温泉大道882号', 'poiweight': '0.450402', 'name': '广州南方学院', 'location': '113.679262,23.632583', 'distance': '471.564', 'tel': '020-87828988;020-61787331', 'type': '科教文化服务;学校;高等院校'})\n",
      "(11, {'id': 'B0HGDU92JD', 'direction': '北', 'businessarea': [], 'address': [], 'poiweight': '0.221662', 'name': '广州南方学院教学楼1号', 'location': '113.677077,23.631783', 'distance': '391.548', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(12, {'id': 'B0HGD592BJ', 'direction': '东北', 'businessarea': [], 'address': '温泉大道886号广州南方学院内', 'poiweight': '0.221662', 'name': '广州南方学院综合楼', 'location': '113.680117,23.631544', 'distance': '392.731', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(13, {'id': 'B0FFKP81F0', 'direction': '西北', 'businessarea': [], 'address': '博学路19号附近', 'poiweight': '0.191742', 'name': '教学楼1号(文学与传媒学院)', 'location': '113.676866,23.631736', 'distance': '393.93', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'})\n",
      "(14, {'id': 'B0FFLBEOND', 'direction': '东北', 'businessarea': [], 'address': '从莞深高速(广州南方学院)', 'poiweight': '0.190963', 'name': '聚贤楼10号', 'location': '113.681253,23.631036', 'distance': '418.51', 'tel': [], 'type': '商务住宅;住宅区;宿舍'})\n",
      "(15, {'id': 'B0FFH6K3U9', 'direction': '西北', 'businessarea': [], 'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层', 'poiweight': '0.254885', 'name': '广州中大南方招待所', 'location': '113.676330,23.631332', 'distance': '378.102', 'tel': '020-61787222', 'type': '住宿服务;住宿服务相关;住宿服务相关'})\n",
      "(16, {'id': 'B0HGD58NF8', 'direction': '北', 'businessarea': [], 'address': '温泉大道882号广州南方学院新综合楼2层', 'poiweight': '0.191229', 'name': '广州南方学院达人书院', 'location': '113.679041,23.632392', 'distance': '446.366', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'})\n",
      "(17, {'id': 'B0FFKUVYWV', 'direction': '东北', 'businessarea': [], 'address': '保利桃花源', 'poiweight': '0.273168', 'name': '广州和风庭阿七度假别墅', 'location': '113.681736,23.630569', 'distance': '424.35', 'tel': '18681565305', 'type': '住宿服务;住宿服务相关;住宿服务相关'})\n",
      "(18, {'id': 'B0HGDU99RM', 'direction': '北', 'businessarea': [], 'address': '温泉大道882号广州南方学院内', 'poiweight': '0.257947', 'name': '广州南方学院图书馆', 'location': '113.679177,23.632762', 'distance': '489.331', 'tel': '020-61787368;020-61787371', 'type': '科教文化服务;图书馆;图书馆'})\n",
      "(19, {'id': 'B0HGDU92JC', 'direction': '北', 'businessarea': [], 'address': '博学路附近', 'poiweight': '0.221662', 'name': '广州南方学院4号实验楼', 'location': '113.679963,23.632652', 'distance': '498.883', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(20, {'id': 'B0FFL7C054', 'direction': '北', 'businessarea': [], 'address': '温泉镇博学路882号(广州南方学院商业中心1层)', 'poiweight': '0.317505', 'name': '广州U优森特酒店', 'location': '113.679226,23.632528', 'distance': '464.819', 'tel': '15813395296', 'type': '住宿服务;住宿服务相关;住宿服务相关'})\n",
      "(21, {'id': 'B0FFG8CSEK', 'direction': '东北', 'businessarea': [], 'address': '从莞深高速(广州南方学院)', 'poiweight': '0.185371', 'name': 'L5员工宿舍', 'location': '113.682583,23.631487', 'distance': '554.129', 'tel': [], 'type': '商务住宅;住宅区;宿舍'})\n",
      "(22, {'id': 'B0HGD58FR2', 'direction': '北', 'businessarea': [], 'address': '广州南方学院', 'poiweight': '0.221662', 'name': '广州南方学院教学楼9号', 'location': '113.679747,23.633032', 'distance': '532.163', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(23, {'id': 'B0HG5Z9JNK', 'direction': '北', 'businessarea': [], 'address': '博学路', 'poiweight': '0.221553', 'name': '广州南方学院教学楼7号', 'location': '113.678600,23.633330', 'distance': '544.868', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(24, {'id': 'B0HGD599JM', 'direction': '北', 'businessarea': [], 'address': '温泉大道882号广州南方学院', 'poiweight': '0.221662', 'name': '广州南方学院第11教学楼', 'location': '113.680037,23.633173', 'distance': '556.036', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(25, {'id': 'B0GUJYPEG2', 'direction': '北', 'businessarea': [], 'address': '温泉大道882号广州南方学院内博学路6号之3', 'poiweight': '0.216026', 'name': '怒烤烤串(从化店)', 'location': '113.677160,23.632910', 'distance': '510.112', 'tel': [], 'type': '餐饮服务;中餐厅;特色/地方风味餐厅'})\n",
      "(26, {'id': 'B0HGDU6Z41', 'direction': '北', 'businessarea': [], 'address': '温泉大道882', 'poiweight': '0.221662', 'name': '广州南方学院教学楼6号', 'location': '113.678424,23.633710', 'distance': '586.331', 'tel': [], 'type': '科教文化服务;学校;学校'})\n",
      "(27, {'id': 'B0HGD580NZ', 'direction': '北', 'businessarea': [], 'address': '博学路7号附近', 'poiweight': '0.285712', 'name': '广州南方学院惟贤门', 'location': '113.678437,23.633721', 'distance': '587.601', 'tel': [], 'type': '科教文化服务;学校;高等院校'})\n",
      "(28, {'id': 'B0HGDU7T1K', 'direction': '北', 'businessarea': [], 'address': '从莞深高速(广州南方学院)', 'poiweight': '0.191229', 'name': '广州南方学院教学楼10号', 'location': '113.680125,23.633492', 'distance': '592.504', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'})\n",
      "(29, {'id': 'B0HGDU76L1', 'direction': '北', 'businessarea': [], 'address': '中山路与博学路交叉口东南150米', 'poiweight': '0.221662', 'name': '广州南方学院教学楼5号', 'location': '113.678046,23.633982', 'distance': '616.848', 'tel': [], 'type': '科教文化服务;学校;学校'})\n"
     ]
    }
   ],
   "source": [
    "all_pois_name=[]\n",
    "for item in enumerate(all_pois):\n",
    "    print(item)\n",
    "    if item == 'name':\n",
    "        print(item)\n",
    "        all_pois_name.append('name')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81ff6e6f",
   "metadata": {},
   "source": [
    "### 询问课代表后学习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "4a212f9a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a是 [{'id': '020F49F0050461206', 'location': '113.678,23.6284', 'direction': '北', 'name': '博学路', 'distance': '7.63232'}, {'id': '020F49F0050462229', 'location': '113.679,23.6245', 'direction': '北', 'name': '老虎形街', 'distance': '445.159'}, {'id': '020F49F0050462451', 'location': '113.677,23.6347', 'direction': '南', 'name': '中山路', 'distance': '708.299'}] \n",
      "\n",
      "b是 博学路 \n",
      "\n",
      "c是 北 \n",
      "\n",
      "所有的name是 ['广州南方公寓', '保利半山花园', '教工住宅1号', '中南公寓', '广州南方学院教学楼4号', '地下铁', '广州南方学院2号实验楼', '教学楼3号(外国语学院)', '广州南方学院1号实验楼', '广州南方学院2号教学楼', '广州南方学院', '广州南方学院教学楼1号', '广州南方学院综合楼', '教学楼1号(文学与传媒学院)', '聚贤楼10号', '广州中大南方招待所', '广州南方学院达人书院', '广州和风庭阿七度假别墅', '广州南方学院图书馆', '广州南方学院4号实验楼', '广州U优森特酒店', 'L5员工宿舍', '广州南方学院教学楼9号', '广州南方学院教学楼7号', '广州南方学院第11教学楼', '怒烤烤串(从化店)', '广州南方学院教学楼6号', '广州南方学院惟贤门', '广州南方学院教学楼10号', '广州南方学院教学楼5号']\n",
      "\n",
      "\n",
      "[1, '广州南方公寓', '113.678983,23.627778', 2, '保利半山花园', '113.679358,23.627672', 3, '教工住宅1号', '113.678490,23.630432', 4, '中南公寓', '113.680349,23.627573', 5, '广州南方学院教学楼4号', '113.677460,23.630490', 6, '地下铁', '113.677941,23.629029', 7, '广州南方学院2号实验楼', '113.678211,23.630956', 8, '教学楼3号(外国语学院)', '113.677247,23.630947', 9, '广州南方学院1号实验楼', '113.678215,23.631370', 10, '广州南方学院2号教学楼', '113.677060,23.631346', 11, '广州南方学院', '113.679262,23.632583', 12, '广州南方学院教学楼1号', '113.677077,23.631783', 13, '广州南方学院综合楼', '113.680117,23.631544', 14, '教学楼1号(文学与传媒学院)', '113.676866,23.631736', 15, '聚贤楼10号', '113.681253,23.631036', 16, '广州中大南方招待所', '113.676330,23.631332', 17, '广州南方学院达人书院', '113.679041,23.632392', 18, '广州和风庭阿七度假别墅', '113.681736,23.630569', 19, '广州南方学院图书馆', '113.679177,23.632762', 20, '广州南方学院4号实验楼', '113.679963,23.632652', 21, '广州U优森特酒店', '113.679226,23.632528', 22, 'L5员工宿舍', '113.682583,23.631487', 23, '广州南方学院教学楼9号', '113.679747,23.633032', 24, '广州南方学院教学楼7号', '113.678600,23.633330', 25, '广州南方学院第11教学楼', '113.680037,23.633173', 26, '怒烤烤串(从化店)', '113.677160,23.632910', 27, '广州南方学院教学楼6号', '113.678424,23.633710', 28, '广州南方学院惟贤门', '113.678437,23.633721', 29, '广州南方学院教学楼10号', '113.680125,23.633492', 30, '广州南方学院教学楼5号', '113.678046,23.633982']\n"
     ]
    }
   ],
   "source": [
    "#### 请完成如下字典操作和列表操作的目标：\n",
    "# * 1. 取出一个'roads'\n",
    "# * 2. 取出一个'roads' 的 'name' 道路名字\n",
    "# * 3. 取出一个'roads' 的 'direction' 路的朝向\n",
    "\n",
    "a=广州南方学院['regeocode']['roads']\n",
    "print('a是',a,'\\n')\n",
    "b=广州南方学院['regeocode']['roads'][0]['name']\n",
    "print('b是',b,'\\n')\n",
    "c=广州南方学院['regeocode']['roads'][0]['direction']\n",
    "print('c是',c,'\\n')\n",
    "# -----\n",
    "# * 进阶：\n",
    "# * 4. 取出对应的 pois name 所对应的 name 并存成一个list 如name_list = [...]\n",
    "# * 5. 取出所有的 pois name 以及其对应的 信息 并分别存成对应的list 如name_location_list = [...]\n",
    "i=0\n",
    "e=[]\n",
    "for item in 广州南方学院['regeocode']['pois']:\n",
    "    d=广州南方学院['regeocode']['pois'][i]['name']\n",
    "    try:\n",
    "        \n",
    "        i+=1\n",
    "        e.append(d)\n",
    "        \n",
    "        \n",
    "    except:\n",
    "        continue\n",
    "print('所有的name是',e)\n",
    "print('\\n')\n",
    "\n",
    "\n",
    "i=0\n",
    "f=[]\n",
    "for item in 广州南方学院['regeocode']['pois']:\n",
    "    d=广州南方学院['regeocode']['pois'][i]['name']\n",
    "    h=广州南方学院['regeocode']['pois'][i]['location']\n",
    "    try:\n",
    "        \n",
    "        i+=1\n",
    "        f.append(i)\n",
    "        f.append(d)\n",
    "        f.append(h)\n",
    "        \n",
    "        \n",
    "        \n",
    "        \n",
    "    except:\n",
    "        \n",
    "        continue\n",
    "print(f)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "129374f6",
   "metadata": {},
   "source": [
    "## 购物车（更新）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "9aaef148",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入您的余额：50\n",
      "------- 请选择编号 欢迎选购 -------\n",
      "商品编号：0 ，商品名称：珍珠奶茶,商品价格：7\n",
      "商品编号：1 ，商品名称：大杯珍珠奶茶,商品价格：8.5\n",
      "商品编号：2 ，商品名称：加大杯珍珠奶茶,商品价格：9.5\n",
      "商品编号：3 ，商品名称：桶装珍珠奶茶,商品价格：20\n",
      "请正确输入购买商品的编号：3\n",
      "【桶装珍珠奶茶】已经加入您的购物车，您的【账户余额】还有：30 元\n",
      "------- 请选择编号 欢迎选购 -------\n",
      "商品编号：0 ，商品名称：珍珠奶茶,商品价格：7\n",
      "商品编号：1 ，商品名称：大杯珍珠奶茶,商品价格：8.5\n",
      "商品编号：2 ，商品名称：加大杯珍珠奶茶,商品价格：9.5\n",
      "商品编号：3 ，商品名称：桶装珍珠奶茶,商品价格：20\n",
      "请正确输入购买商品的编号：1\n",
      "【大杯珍珠奶茶】已经加入您的购物车，您的【账户余额】还有：21.5 元\n",
      "------- 请选择编号 欢迎选购 -------\n",
      "商品编号：0 ，商品名称：珍珠奶茶,商品价格：7\n",
      "商品编号：1 ，商品名称：大杯珍珠奶茶,商品价格：8.5\n",
      "商品编号：2 ，商品名称：加大杯珍珠奶茶,商品价格：9.5\n",
      "商品编号：3 ，商品名称：桶装珍珠奶茶,商品价格：20\n",
      "请正确输入购买商品的编号：2\n",
      "【加大杯珍珠奶茶】已经加入您的购物车，您的【账户余额】还有：12.0 元\n",
      "------- 请选择编号 欢迎选购 -------\n",
      "商品编号：0 ，商品名称：珍珠奶茶,商品价格：7\n",
      "商品编号：1 ，商品名称：大杯珍珠奶茶,商品价格：8.5\n",
      "商品编号：2 ，商品名称：加大杯珍珠奶茶,商品价格：9.5\n",
      "商品编号：3 ，商品名称：桶装珍珠奶茶,商品价格：20\n",
      "请正确输入购买商品的编号：3\n",
      "您的余额不足，请更换支付方式\n",
      "------- 请选择编号 欢迎选购 -------\n",
      "商品编号：0 ，商品名称：珍珠奶茶,商品价格：7\n",
      "商品编号：1 ，商品名称：大杯珍珠奶茶,商品价格：8.5\n",
      "商品编号：2 ，商品名称：加大杯珍珠奶茶,商品价格：9.5\n",
      "商品编号：3 ，商品名称：桶装珍珠奶茶,商品价格：20\n",
      "请正确输入购买商品的编号：q\n",
      "用户购物车： [('桶装珍珠奶茶', 20), ('大杯珍珠奶茶', 8.5), ('加大杯珍珠奶茶', 9.5)]\n",
      "您的余额还有： 12.0\n"
     ]
    }
   ],
   "source": [
    "# 商品的数据信息\n",
    "goods_list = [\n",
    "    #[商品名称，商品价格],\n",
    "    ('珍珠奶茶',7),\n",
    "    ('大杯珍珠奶茶',8.5),\n",
    "    ('加大杯珍珠奶茶',9.5),\n",
    "    ('桶装珍珠奶茶',20)\n",
    "]\n",
    "user_shopping_car = [\n",
    "    \n",
    "]\n",
    "\n",
    "# 用户输入 使用input ，input的使用，结果是一个字符串\n",
    "Alipay = int(input(\"请输入您的余额：\"))\n",
    "\n",
    "while True:\n",
    "    # 循环遍历商品列表，将商品信息按照一定格式输出\n",
    "    # 一定格式： 商品编号：xx ，商品名称：xx,商品价格：xx\n",
    "    print(\"------- 请选择编号 欢迎选购 -------\")\n",
    "    for i in range(len(goods_list)): # range会根据商品列表的长度变化而变化\n",
    "        print(\"商品编号：%s ，商品名称：%s,商品价格：%s\"%(i,goods_list[i][0],goods_list[i][1]))\n",
    "\n",
    "    # 2.让用户输入商品编号进行商品的购买\n",
    "    # 1. 用户输入的内容是否符合规范（用户买的东西有没有）？\n",
    "\n",
    "    # 思考：用户除了输入数值外，有没有可能输入不是数值\n",
    "\n",
    "    choice = input(\"请正确输入购买商品的编号：\")\n",
    "    if choice.isdigit(): # isdigit 判断字符串里面的内容是否是数值\n",
    "        choice = int(choice)\n",
    "        if choice > len(goods_list):\n",
    "            #   b. 如果没有该商品，返回没有\n",
    "            print(\"您选择的商品不存在\")\n",
    "        else:\n",
    "            #   a. 如果有 判断金额是否够 : 用户金额 Alipay  商品的金额 goods_list[choice][1]\n",
    "            if Alipay > goods_list[choice][1]:\n",
    "                # 用户余额够 1. 增加该商品到用户购物车 2.扣除余额\n",
    "                user_shopping_car.append(goods_list[choice])\n",
    "                Alipay = Alipay - goods_list[choice][1]\n",
    "                print(\"【%s】已经加入您的购物车，您的【账户余额】还有：%s 元\"%(goods_list[choice][0],Alipay))\n",
    "            else:\n",
    "                print(\"您的余额不足，请更换支付方式\")\n",
    "    elif choice == \"q\":\n",
    "        # 用户退出购买\n",
    "        print(\"用户购物车：\",user_shopping_car)\n",
    "        print(\"您的余额还有：\",Alipay)\n",
    "        break\n",
    "    else:\n",
    "        print(\"请输入商品编号！！！\")\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c3e4526",
   "metadata": {},
   "source": [
    "## 集合 （课本练习P123）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "bf300878",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'i', 'o', 'u'}"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 集合不允许有重复\n",
    "vowels = {'a','e','e','i','o','u','u'}\n",
    "vowels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "62ef1932",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'i', 'o', 'u'}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# vowels = {'a','e','e','i','o','u','u'}\n",
    "# vowels\n",
    "vowels2 = set('aeeiouu')\n",
    "vowels2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c944a785",
   "metadata": {},
   "outputs": [],
   "source": [
    "vowels = set('aeiou')\n",
    "word = 'hello'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "7cfe60a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a', 'e', 'h', 'i', 'l', 'o', 'u']"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# union 合并集合\n",
    "u = vowels.union(set(word))\n",
    "u_list = sorted(list(u))\n",
    "u_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "9f19e0ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'i', 'u'}"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# difference 告诉你哪些不是共有元素\n",
    "d = vowels.difference(set(word))\n",
    "d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "d6bf47d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'e', 'o'}"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# intersection 报告共同对象\n",
    "i = vowels.intersection(set(word))\n",
    "i"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
